<!DOCTYPE html >
<html>
<head>
    <link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
    
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.common.key.js" ></script>
    <script src="../libraries/RGraph.bar.js" ></script>
    <!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->
    
    <title>A stacked bar chart</title>
</head>
<body>
        
    <h1>A stacked bar chart</h1>
    
    <p>
        This is a stacked Bar chart. The labels that are inside the bars are achieved by using a DOM1 style ondraw event.
    </p>

    <canvas id="cvs" width="700" height="350">[No canvas support]</canvas>

    <script>
        window.onload = function ()
        {
            var bar = new RGraph.Bar('cvs', [[5.33,2.33,3.32],[3.42,2.23,4.23],[4.23,3.23,4.99], [7.99,2.98,2.35], [2.75,1.02,5.24]])
            bar.Set('chart.grouping', 'stacked');
            bar.Set('chart.labels', ['John','James','Fred','Luke','Luis']);
            bar.Set('chart.labels.above', true);
            bar.Set('chart.labels.above.decimals', 2);
            bar.Set('chart.linewidth', 2);
            bar.Set('chart.strokestyle', 'white');
            bar.Set('chart.colors', ['Gradient(#4572A7:#66f)','Gradient(#AA4643:white)','Gradient(#89A54E:white)']);
            bar.Set('chart.shadow', true);
            bar.Set('chart.shadow.offsetx', 1);
            bar.Set('chart.shadow.offsety', 1);
            bar.Set('chart.shadow.blue', 5);
            bar.Set('chart.hmargin', 25);
            bar.Set('chart.gutter.left', 45);
            bar.Set('chart.background.grid.vlines', false);
            bar.Set('chart.background.grid.border', false);
            bar.Set('chart.axis.color', '#ccc');
            bar.Set('chart.noyaxis', true);
            bar.Set('chart.key', ['Monday','Tuesday','Wednesday']);
            bar.Set('chart.key.position', 'gutter');
            bar.Set('chart.key.position.x', bar.canvas.width - 300);
            bar.Set('chart.key.position.y', 20);
            bar.Set('chart.key.colors', ['blue','#c00','#0c0']);
            
            bar.ondraw = function (obj)
            {
                for (var i=0; i<obj.coords.length; ++i) {
                    obj.context.fillStyle = 'white';
                    RGraph.Text(obj.context, 'Verdana', 10, obj.coords[i][0] + (obj.coords[i][2] / 2), obj.coords[i][1] + (obj.coords[i][3] / 2),obj.data_arr[i].toString(),'center', 'center', null,null,null,true);
                }
            }
            
            bar.Draw();
        }
    </script>


    <p>
        <a href="./">&laquo; Back</a>
    </p>

</body>
</html>